#include "ObjectManager.h"

ObjectManager * ObjectManager::m_ObjectManager=NULL;

ObjectManager::ObjectManager()
{
	m_Hero=new Man;
//	m_hinderBatchNode=CCSpriteBatchNode::create();
	m_hinderBatchNode->retain();
	m_hinders=NULL;
	m_OtherSprite.clear();
	init_Sprite();
}

ObjectManager::~ObjectManager()
{
	CC_SAFE_RELEASE(m_Hero);
	m_hinderBatchNode->release();
	CC_SAFE_DELETE_ARRAY(m_hinders);
	delete_Sprite();
}

CCSprite *ObjectManager::GetSprite(SpriteID id)
{
	std::map<SpriteID,CCSprite*>::iterator i=m_OtherSprite.find(id);
	if (NULL!=i->second)
	{
		return i->second;
	}
	return NULL;
};

void ObjectManager::init_Sprite()
{
	m_OtherSprite.insert(std::pair<SpriteID,CCSprite*>(map_1,CCSprite::create("scene/map_1.png")));

	std::map<SpriteID,CCSprite*>::iterator i=m_OtherSprite.begin();
	for(;i!=m_OtherSprite.end();i++)
	{
		i->second->retain();
	}
}

void ObjectManager::delete_Sprite()
{
	std::map<SpriteID,CCSprite*>::iterator i=m_OtherSprite.begin();
	for(;i!=m_OtherSprite.end();i++)
	{
		CC_SAFE_RELEASE(i->second);
	}
	m_OtherSprite.clear();
}